package com.mall.malllibrary.activities

import android.os.Bundle
import android.widget.FrameLayout
import com.mall.malllibrary.R
import com.mall.malllibrary.fragments.MallFragment
import me.yokeyword.fragmentation.ExtraTransaction
import me.yokeyword.fragmentation.SupportActivity
import me.yokeyword.fragmentation.SupportActivityDelegate
import me.yokeyword.fragmentation.anim.DefaultHorizontalAnimator
import me.yokeyword.fragmentation.anim.FragmentAnimator

abstract class ProxyActivity : SupportActivity() {


    // 设置根承载fragment,用于外面传入
    abstract fun setRootFragment(): MallFragment

    // 覆盖对应的方法
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        initContainer(savedInstanceState)
    }

    // 私有初始化方法加载容器视图
    private fun initContainer(savedInstanceState: Bundle?) {
        val container = FrameLayout(this)
        container.id = R.id.fragment_container
        setContentView(container)
        if (savedInstanceState==null){

           loadRootFragment(R.id.fragment_container, setRootFragment())
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        System.gc()
        System.runFinalization()
    }

    override fun post(runnable: Runnable?) {
        post(runnable)

    }
//
//    override fun extraTransaction(): ExtraTransaction {
//        return mDelegate.extraTransaction()
//    }
//
//    override fun getFragmentAnimator(): FragmentAnimator {
//        return mDelegate.fragmentAnimator
//    }
//
//    override fun setFragmentAnimator(fragmentAnimator: FragmentAnimator?) {
//        mDelegate.fragmentAnimator = DefaultHorizontalAnimator()
//    }
//
//    override fun onCreateFragmentAnimator(): FragmentAnimator {
//        return mDelegate.onCreateFragmentAnimator()
//    }
//
//    override fun onBackPressedSupport() {
//        mDelegate.onBackPressedSupport()
//    }



}